import 'dart:convert';

import '../model/base_change_notifier.dart';
import '../model/common_item.dart';
import '../utils/history_repository.dart';


class WatchHistoryViewModel extends BaseChangeNotifier {
  List<Data> itemList = [];
  List<String> watchList = [];

  void loadData() {
    watchList = HistoryRepository.loadHistoryData();
    var list = watchList.map((value) {
      return Data.fromJson(json.decode(value));
    }).toList();
    itemList = list;
    notifyListeners();
  }

  void remove(int index) {
    watchList.removeAt(index);
    HistoryRepository.saveHistoryData(watchList);
    loadData();
  }
}